package com.sunfeng.chap1;

import java.nio.ByteBuffer;

/**
 * @Author : 孙峰
 * @Description: 如果定义了 mark 在将 limit 调整为不小于该 mark 的值时 ，该mark不丢弃
 * @Date : 2021/10/8  9:57
 */
public class Test4_3 {
    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[]{1, 2, 3});
        System.out.println("A " + byteBuffer.position() + "   " + byteBuffer.limit());
        System.out.println();
        byteBuffer.position(2);
        byteBuffer.mark();
        System.out.println("B " + byteBuffer.position() + "   " + byteBuffer.limit());
        byteBuffer.position(3);
        byteBuffer.limit(3);
        System.out.println();
        System.out.println("C " + byteBuffer.position() + "   " + byteBuffer.limit());
        byteBuffer.reset();
        System.out.println();
        System.out.println("D " + byteBuffer.position() + "   " + byteBuffer.limit());

    }
}
